/*
 * Copyright (c) 2014, Asiainfo-Linkage. All rights reserved.
 * Asiainfo-Linkage PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package edu.w106.platform.mc;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * <p><b>标题：</b>MessageCenter.</p>
 *
 * <p><b>描述：</b></p>
 *
 * <p><b>版权：</b>Copyright (c) 2014 亚信联创</p>
 *
 * <p><b>工程：</b>w106-mc</p>
 *
 * @author w106
 *
 * @version 1.0.0
 *
 * @since 2014-4-30 下午3:54:40
 */
public abstract class MessageCenter implements IMessage {

    protected final Queue<Message> receMsg = new ConcurrentLinkedQueue<Message>();

    private final int MAX_SIZE = 1000;

    /* (non-Javadoc)
     * @see edu.w106.platform.mc.ITray#addMessage(edu.w106.platform.mc.Message)
     */

    /**
     * 超过最大消息限制，丢弃.
     */
    @Override
    public void addMessage(Message msg) {
        if (receMsg.size() > MAX_SIZE) {
            receMsg.poll();
        }
        receMsg.add(msg);

    }

}
